package com.xjtu.platform.security.loginByMail.Impl;

import com.xjtu.platform.security.loginByMail.LoginByMailDto;
import com.xjtu.platform.security.loginByMail.LoginByMailService;
import com.xjtu.platform.security.loginByMail.dao.LoginByMailDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class LoginByMailServiceImpl implements LoginByMailService {

    @Resource
    private LoginByMailDao loginByMailDao;

    @Override
    public boolean checkLoginMail(LoginByMailDto loginByMailDto) {
        try {
            int count = loginByMailDao.checkLogin(loginByMailDto);

            return count > 0;
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public String getWeb(LoginByMailDto loginByMailDto) {
        try {
            String web = loginByMailDao.getWeb(loginByMailDto);
            return web;
        }catch (Exception e){

            e.printStackTrace();
            return "error";
        }
    }

    @Override
    public String getUser_id(LoginByMailDto loginByMailDto) {
        try {
            String user_id = loginByMailDao.getUser_id(loginByMailDto);
            return user_id;
        }catch (Exception e){
            e.printStackTrace();
            return "error";
        }
    }
}
